using System;
using System.Diagnostics;

namespace Mbs.ComponentModel
{
    [AttributeUsage(AttributeTargets.Field)]
    [DebuggerDisplay("Description={Description}")]
    public class EnumDescriptionAttribute : Attribute
    {
        public string DefaultDescription { get; set; }
        public int Rank { get; set; }
        public string ResourceKey { get; set; }

        internal string FieldName { get; set; }
        internal Enum Value { get; set; }

        public string Description
        {
            get
            {
                if (!string.IsNullOrEmpty(ResourceKey))
                    return ResourceKey.StringResource();
                if (!string.IsNullOrEmpty(DefaultDescription))
                    return DefaultDescription;
                return FieldName;
            }
        }
        public override string ToString()
        {
            return Description;
        }
    }
}
